<?php
class Deal_model extends MY_Model {

	var $item_id= null;
	var $tenant_id = null;
	var $discount = null;
	var $price = null;
	var $item_quantity = null;
	var $status = null;
	var $description = null;
	var $dealtype = null;
	var $deal_end_date = null;
	var $deal_category_id = null;
	var $ishotdeal = 0;
	
	function __construct() {
		parent::__construct(); 
	}

	public function loadDealsByType($dealType){
		$sql = "select d.id as id, d.deal_end_date as deal_end_date, d.item_id as item_id ,i.code as code, i.price as price , i.name as  name ,d.discount as discount, i.available_qty as quantity, d.ishotdeal as ishotdeal, ";
		$sql .= "d.dealtype as dealtype , d.description as description from deal as d, item as i where d.item_id = i.id and";
		$sql .= " d.valid  = ? and dealtype = ?";
		
		//ECHO $sql;
		return $this->db->query($sql, array(1,$dealType))->result();
	}
	
	public function viewDealDetails($id){
		$sql = "select d.id as id, d.deal_end_date as deal_end_date, d.item_id as item_id ,i.code as code, i.price as price , i.name as  name ,d.discount as discount, i.available_qty as quantity, d.ishotdeal as ishotdeal, ";
		$sql .= "d.dealtype as dealtype , d.tenant_id as tenant_id ,  d.description as description from deal as d, item as i where d.item_id = i.id and";
		$sql .= " d.valid  = ? and d.id = ?";
		
		//ECHO $sql;
		return $this->db->query($sql, array(1,$id))->result();
	}
}
?>